package com.woniu.woniuk16.controller;


import com.woniu.woniuk16.exception.stu.CourceExceprion;
import com.woniu.woniuk16.model.Result;
import com.woniu.woniuk16.param.AddScore;
import com.woniu.woniuk16.service.IWoniuStudentScoreService;
import com.woniu.woniuk16.service.WoniuStudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author tiangle
 * @since 2021-12-26
 */
@RestController
@RequestMapping("/woniuStudentScore")
public class WoniuStudentScoreController {
    @Autowired
    private IWoniuStudentScoreService iWoniuStudentScoreService;

    @GetMapping("/one/{id}")
    public Result getOnes(@PathVariable Integer id) throws CourceExceprion {
        Object one = iWoniuStudentScoreService.getOne(id);
        return Result.getInstance(one);
    }

    @PostMapping("/add")
    public Result addOne(@RequestBody AddScore addScore) throws CourceExceprion {
        iWoniuStudentScoreService.addOne(addScore);
        return Result.getInstance(null);
    }

    @GetMapping("/del/{id}")
    public Result delOne(@PathVariable Integer id){
        iWoniuStudentScoreService.delAll(id);
        return Result.getInstance(null);
    }

    @GetMapping("/sub/{id}")
    public Result submit(@PathVariable Integer id) throws CourceExceprion {
        iWoniuStudentScoreService.submit(id);
        return Result.getInstance(null);
    }
}

